<%--
  Created by IntelliJ IDEA.
  User: CY
  Date: 2017/12/25
  Time: 14:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>未读信息</title>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" type="text/css" href="/css/patrol/patrol.css"/>
    <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <style>
        .select{
            background-color:#2F8AE3;
            color:#fff;
            border-radius:20px;
            -webkit-border-radius:20px;
            -moz-border-radius:20px;
            -o-border-radius:20px;;
            -ms-border-radius:20px;
        }
        select{
            border-radius: 3px;
            height:28px;
            margin-left:20px;
        }
        #query{
            background: #00a0e9;
            margin-left: 10px;
            padding: 3px 10px;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
        }
        .list a{
            margin:0 3px 0 2px;
        }
    </style>
</head>
<body>
    <div class="content">
        <div style="height:50px;line-height: 50px;">
            <select name="" id="allDept" >
               <%-- <option value="">请选择</option>--%>
            </select>
            <button id="query">查询</button>
        </div>
        <div style="margin: -45px auto 0px;height:50px;width: 97%;" class="clearfix">
            <div id="dbgz_page" class="M-box3">

            </div>
        </div>
        <div class="table">
            <table style="width:98%;margin:0 auto">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>填报部门</th>
                    <th>填报人</th>
                    <th>报送人</th>
                    <th>报送时间</th>
                    <th>标题</th>
                    <th>是否采集</th>
                    <th>是否阅读</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody class="list">
                    <%--<tr>--%>
                        <%--<td>编号</td>--%>
                        <%--<td>报送部门</td>--%>
                        <%--<td>报送人</td>--%>
                        <%--<td>报送时间</td>--%>
                        <%--<td>标题</td>--%>
                        <%--<td>是否采集</td>--%>
                        <%--<td>是否阅读</td>--%>
                        <%--<td>--%>
                            <%--<a href="javascript:;" class="choose" data-type="1">修改</a>--%>
                            <%--<a href="javascript:;" class="detail" data-type="2">查看</a>--%>
                            <%--<a href="javascript:;" class="del" >删除</a>--%>
                        <%--</td>--%>
                    <%--</tr>--%>
                </tbody>
            </table>
        </div>
    </div>
    <script>
     var ajaxPage={
         data:{
             page:1,
             pageSize:10,
             //useFlag:true,
             deptId:null,
             isread:0
         },
         page:function(){
             //列表数据展示
             $.ajax({
                 type:'post',
                 url:'/infomation/getHandleList',
                 data:this.data,
                 dataType:'json',
                 success:function(data){
//                     console.log(data)
                     var res=data.obj;
                     var str='';
                     if(res.length<=0){
                         $.layerMsg({content:'暂无未读信息',icon:6});
                     }else{
                         for (var i = 0; i <res.length; i++){
                             str +='<tr id="'+res[i].id+'">' +
                                 '<td>'+(i+1)+'</td>' +
                                 '<td>'+res[i].deptName+'</td>' +
                                 '<td>'+res[i].userName+'</td>' +
                                 '<td>'+isEmpty(res[i].deliveryDeptName)+'</td>' +
                                 '<td>'+function(){
                                     if(res[i].createTime==undefined){
                                         return ''
                                     }else{
                                         return new Date(res[i].createTime).Format('yyyy-MM-dd hh:mm:ss')
                                     }
                                 }()+'</td>' +
                                 '<td>'+res[i].title+'</td>' +
                                 '<td>'+ function (){if(res[i].iscollection==0){return "否"}else{return "是"}}()+'</td>' +
                                 '<td>' +function (){if(res[i].isread==0){return "否";}else{return "是";}}()+'</td>' +
                                 '<td>' +
                                 '<a href="javascript:;" class="choose" data-type="1">修改</a>' +
                                 '<a href="javascript:;" class="detail" data-type="2">查看</a>' +
                                 '<a href="javascript:;" class="del" >删除</a>' +
                                 '</td>' +
                                 '</tr>'
                         }

                     }
                     $('.list').html(str);

                 }
             })
         },
         init:function(){
             $.ajax({
                 type:'post',
                 url:'/department/getAlldept',
                 dataType:'json',
                 success:function(data){
                     var datas=data.obj;
                     var str = '<option value="">所有科室</option>';
                     for(var i =0 ;i<datas.length;i++){
                        str += '<option value="'+datas[i].deptId+'">'+datas[i].deptName+'</option>'
                     }
                     $('#allDept').html(str);
                 }

             })
         }

     };

//     $(function(){
         ajaxPage.page();
         ajaxPage.init();
         //点击删除
         $('.list').on('click','.del',function(){
             var id=$(this).parents('tr').attr('id');
//             console.log(id)
             layer.confirm(' 确定要删除吗?', {
                 btn: [' 确定', ' 取消'], //按钮
                 title: " 删除"
             },function(){
                 $.ajax({
                     url:'/infomation/delete',
                     type:'post',
                     data:{id:id},
                     dataType:'json',
                     success:function(res){
                         if(res.flag){
                             $.layerMsg({content:'删除成功！',icon:1});
                             ajaxPage.data.page=1;
                             ajaxPage.page();
                         }else{
                             $.layerMsg({content:'删除失败！',icon:1});
                         }
                     }
                 })
             },function(){
                 layer.close();
             })
         });

         //点击查询
         $('#query').click(function(){
            ajaxPage.data.deptId=$('#allDept ').val();
//            console.log(ajaxPage.data.deptId)
                ajaxPage.page();
         });

         <%--点击修改--%>
         $('.list').on('click','.choose',function(){
             var me=$(this)
             var id=me.parents('tr').attr('id')
             parent.document.getElementById('iframe').src='/infomation/readDetail?dataType='+me.attr('data-type')+'&id='+id+'&read='+1+'&is='+0;
         })
//        点击查看
         $('.list').on('click','.detail',function(){
             var me=$(this)
             var id=me.parents('tr').attr('id')
             parent.document.getElementById('iframe').src='/infomation/readDetail?dataType='+me.attr('data-type')+'&id='+id+'&read='+1+'&is='+0;
         })

//     })


     //判断字符是否为空的方法
     function isEmpty(obj){
         if(obj == undefined || obj == "" || obj == null){
             return '';
         }
         return obj;
     }
    </script>
</body>
</html>
